<!--
    Copyright 2008 Jan Molnar <jan.molnar@abds.de>

    This file is part of JCQ.

    JCQ is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    JCQ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with JCQ. If not, see <http://www.gnu.org/licenses/>.
-->

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:JCsTools.JCQ.Ux"
    x:Class="WindowTheme">

    <local:WindowStateToVisibilityConverter x:Key="WindowStateToVisibilityConverter" />

    <LinearGradientBrush x:Key="SystemButtonFill" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FF000000" Offset="1"/>
        <GradientStop Color="#FF3D3D3D" Offset="0"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SystemButtonFillHover" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FF004C81" Offset="1"/>
        <GradientStop Color="#FF0BAFFD" Offset="0"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="SystemButtonFillPressed" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FF003058" Offset="1"/>
        <GradientStop Color="#FF005EBE" Offset="0"/>
    </LinearGradientBrush>
    <Style x:Key="LeftSysBtn" BasedOn="{x:Null}" TargetType="{x:Type Button}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource SystemButtonFillHover}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{StaticResource SystemButtonFillPressed}" />
            </Trigger>
        </Style.Triggers>
        <Setter Property="Background" Value="{StaticResource SystemButtonFill}" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Path Fill="{TemplateBinding Background}" Stretch="Fill" Stroke="{x:Null}">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure IsClosed="True" StartPoint="0,0">
                                        <LineSegment Point="26.95,0" IsSmoothJoin="True"/>
                                        <BezierSegment Point1="26.95,0" Point2="26.95,16" Point3="26.95,16" IsSmoothJoin="True"/>
                                        <BezierSegment Point1="26.95,16" Point2="4,16" Point3="4,16"/>
                                        <BezierSegment Point1="1.8,16" Point2="0,14.2" Point3="0,12" IsSmoothJoin="True"/>
                                        <BezierSegment Point1="0,12" Point2="0,0" Point3="0,0"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Path Stretch="Fill" Stroke="{x:Null}">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                    <GradientStop Color="#00FFFFFF" Offset="0.46"/>
                                    <GradientStop Color="#00FFFFFF" Offset="0"/>
                                    <GradientStop Color="#28FFFFFF" Offset="0.455"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure IsClosed="True" StartPoint="0,0">
                                        <LineSegment Point="26.95,0" IsSmoothJoin="True"/>
                                        <BezierSegment Point1="26.95,0" Point2="26.95,16" Point3="26.95,16" IsSmoothJoin="True"/>
                                        <BezierSegment Point1="26.95,16" Point2="4,16" Point3="4,16"/>
                                        <BezierSegment Point1="1.8,16" Point2="0,14.2" Point3="0,12" IsSmoothJoin="True"/>
                                        <BezierSegment Point1="0,12" Point2="0,0" Point3="0,0"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>


                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RightSysBtn" BasedOn="{x:Null}" TargetType="{x:Type Button}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource SystemButtonFillHover}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{StaticResource SystemButtonFillPressed}" />
            </Trigger>
        </Style.Triggers>
        <Setter Property="Background" Value="{StaticResource SystemButtonFill}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Path Fill="{TemplateBinding Background}" Stretch="Fill" Stroke="{x:Null}" Margin="0,0,0,-0.031">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure IsClosed="True" StartPoint="21,0">
                                        <BezierSegment IsSmoothJoin="True" Point1="24.53125,0" Point2="27,2.86944045911047" Point3="27,6"/>
                                        <LineSegment Point="27,16" IsSmoothJoin="True"/>
                                        <PolyBezierSegment Points="27,16 0,16 0,16 0,16 0,0 0,0"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Path Stretch="Fill" Stroke="{x:Null}">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#00FFFFFF" Offset="0.46"/>
                                    <GradientStop Color="#00FFFFFF" Offset="0"/>
                                    <GradientStop Color="#28FFFFFF" Offset="0.455"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure IsClosed="True" StartPoint="21,0">
                                        <BezierSegment IsSmoothJoin="True" Point1="24.53125,0" Point2="27,2.86944045911047" Point3="27,6"/>
                                        <LineSegment Point="27,16" IsSmoothJoin="True"/>
                                        <PolyBezierSegment Points="27,16 0,16 0,16 0,16 0,0 0,0"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="CenterSysBtn" BasedOn="{x:Null}" TargetType="{x:Type Button}">
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource SystemButtonFillHover}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{StaticResource SystemButtonFillPressed}" />
            </Trigger>
        </Style.Triggers>
        <Setter Property="Background" Value="{StaticResource SystemButtonFill}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid>
                        <Path Fill="{TemplateBinding Background}" Stretch="Fill" Stroke="{x:Null}">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure IsClosed="True" StartPoint="26.95,0">
                                        <LineSegment Point="53.4,0" IsSmoothJoin="True"/>
                                        <PolyBezierSegment Points="53.4,0 53.4,16 53.4,16 53.4,16 26.95,16 26.95,16 26.95,16 26.95,0 26.95,0"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Path Stretch="Fill" Stroke="{x:Null}">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#00FFFFFF" Offset="0.46"/>
                                    <GradientStop Color="#00FFFFFF" Offset="0"/>
                                    <GradientStop Color="#28FFFFFF" Offset="0.455"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure IsClosed="True" StartPoint="26.95,0">
                                        <LineSegment Point="53.4,0" IsSmoothJoin="True"/>
                                        <PolyBezierSegment Points="53.4,0 53.4,16 53.4,16 53.4,16 26.95,16 26.95,16 26.95,16 26.95,0 26.95,0"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SimpleWindow" TargetType="{x:Type Window}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Window}">
                    <Grid x:Name="LayoutRoot" MouseDown="OnMouseDown">
                        <Rectangle Stroke="{x:Null}" RadiusY="6" RadiusX="6">
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF646464" Offset="0.013"/>
                                    <GradientStop Color="#FF393939" Offset="0.781"/>
                                    <GradientStop Color="#FF999999" Offset="0"/>
                                    <GradientStop Color="#FF333333" Offset="0.938"/>
                                    <GradientStop Color="#FF121212" Offset="1"/>
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>

                        <TextBlock HorizontalAlignment="Left" Margin="6"  VerticalAlignment="Top" Width="Auto" Height="Auto" TextWrapping="Wrap" FontSize="9" FontWeight="Bold" Foreground="#FFF0F0F0" Text="{TemplateBinding Title}"/>
    							<Rectangle HorizontalAlignment="Right"  VerticalAlignment="Top" Width="80" Height="16" Stroke="{x:Null}" RadiusX="4" RadiusY="4">
    								<Rectangle.Fill>
    									<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    										<GradientStop Color="#FFCACACA" Offset="1"/>
    										<GradientStop Color="#00847C7C" Offset="0.25"/>
    										<GradientStop Color="#00FFFFFF" Offset="0.134"/>
    									</LinearGradientBrush>
    								</Rectangle.Fill>
    							</Rectangle>
		
						<Button  Click="OnWindowMinimize"  HorizontalAlignment="Right" Margin="0,0,53.2,0" Style="{DynamicResource LeftSysBtn}" VerticalAlignment="Top" Width="27" Height="16">
			<Path Width="15.917" Height="1.392" Fill="{x:Null}" Stretch="Fill" Stroke="#FFFFFFFF" Data="M4.8666667,11.166667 C9.7868418,11.166667 14.931288,10.561417 19.783333,11.333333" Margin="0,10,0,0"/>
		</Button>
		<Button Visibility="{TemplateBinding WindowState, Converter={StaticResource WindowStateToVisibilityConverter}, ConverterParameter=restore}"  Click="OnWindowRestore"  HorizontalAlignment="Right" Margin="0,0,26.7,0" Style="{DynamicResource CenterSysBtn}" VerticalAlignment="Top" Width="27" Height="16">
			<Path Width="14.5" Height="10.364" Fill="{x:Null}" Stretch="Fill" Stroke="#FFFFFFFF" Data="M6.1166667,8.8333333 C6.4453156,9.9726497 6.3401466,11.007546 6.5333333,12.166667 6.6543814,12.892955 6.125316,12.782331 7.2,12.916667 8.1478179,13.035144 9.0685501,13 10.033333,13 11.626653,13 13.116667,14.540178 13.116667,12 13.116667,11.190094 12.832793,10.067748 13.2,9.3333333 11.19569,8.3311784 8.3102971,9.8468152 6.45,8.9166667 10.210898,8.9166667 10.033333,11.266961 10.033333,4.6666667 11.176753,4.4760968 17.092244,3.4903052&#xd;&#xa;18.033333,4.6666667 19.685618,6.7320226 19.616667,10.369586 19.616667,13.25 17.436938,12.160136 13.935583,12.916667 11.366667,12.916667 11.049439,12.916667 10.607518,9.3993655 10.533333,8.5833333"/>
		</Button>
		<Button Visibility="{TemplateBinding WindowState, Converter={StaticResource WindowStateToVisibilityConverter}, ConverterParameter=maximize}"  Click="OnWindowMaximize"  HorizontalAlignment="Right" Margin="0,0,26.7,0" Style="{DynamicResource CenterSysBtn}" VerticalAlignment="Top" Width="27" Height="16">
			<Path Width="17.167" Height="12.201" Fill="{x:Null}" Stretch="Fill" Stroke="#FFFFFFFF" Data="M5.7833333,3.9166667 C6.4932909,5.9630148 6.7833333,8.1686649 6.7833333,10.416667 6.7833333,11.80501 6.2391179,12.765293 6.0333333,14 10.840771,14 15.700558,13.833333 20.533333,13.833333 20.533333,11.478339 21.2,9.1506088 21.2,6.75 21.2,5.957532 20.99414,5.2648424 20.866667,4.5 20.753712,3.8222723 21.24734,3.5781914 20.116667,3.4166667 16.709504,2.9299291 13.244854,3.3333333 9.7833333,3.3333333 8.1273524,3.3333333 6.6323331,2.6403506&#xd;&#xa;5.0333333,2.8333333"/>
		</Button>
		<Button Click="OnWindowClose"  HorizontalAlignment="Right" Margin="0,0,0.1,0" Style="{DynamicResource RightSysBtn}" VerticalAlignment="Top" Width="27" Height="16">
			<Path Width="15" Height="10.583" Stretch="Fill" Stroke="#FFFFFFFF" Data="M3.9333333,14.083333 C7.6785781,11.778567 10.699887,8.5476998 14.266667,6 15.535527,5.093671 17.134037,4.6423545 18.266667,3.8333333 15.476195,3.8333333 12.822817,6.395387 10.35,8.25 11.854494,9.252996 13.338509,10.440807 14.766667,11.583333 15.781933,12.395546 17.507832,14.416667 18.933333,14.416667 15.470992,13.262553 12.247921,11.051828 9.6833333,8.1666667 8.5063844,6.8425991 7.1201658,6.2933223 5.7666667,5.25" Fill="{x:Null}"/>
		</Button>
		
    							<ContentPresenter Margin="0,20,0,0" />
    							
    							<!-- <Sizing Contols Area> -->

                        <Line MouseDown="OnSizeNorth" Name="lnSizeNorth" Cursor="SizeNS" X1="1" X2="{Binding ElementName=LayoutRoot, Path=ActualWidth}" Y1="1" Y2="1" Stroke="Transparent" StrokeThickness="2" />
                        <Line MouseDown="OnSizeSouth" Name="lnSizeSouth" VerticalAlignment="Bottom" Cursor="SizeNS" X1="1" X2="{Binding ElementName=LayoutRoot, Path=ActualWidth}" Y1="{Binding ElementName=LayoutRoot, Path=ActualHeight}" Y2="{Binding ElementName=LayoutRoot, Path=ActualHeight}" Stroke="Transparent" StrokeThickness="2" />
                        <Line MouseDown="OnSizeWest" Name="lnSizeWest" Cursor="SizeWE" X1="1" X2="1" Y1="1" Y2="{Binding ElementName=LayoutRoot, Path=ActualHeight}" Stroke="Transparent" StrokeThickness="2" />
                        <Line MouseDown="OnSizeEast" Name="lnSizeEast" HorizontalAlignment="Right" Cursor="SizeWE" X1="{Binding ElementName=LayoutRoot, Path=ActualWidth}" X2="{Binding ElementName=LayoutRoot, Path=ActualWidth}" Y1="1" Y2="{Binding ElementName=LayoutRoot, Path=ActualHeight}" Stroke="Transparent" StrokeThickness="2" />

                        <Rectangle MouseDown="OnSizeNorthWest" Name="rectSizeNorthWest" Cursor="SizeNWSE" Fill="Transparent"    Width="10" Height="10" VerticalAlignment="Top" HorizontalAlignment="Left" />
                        <Rectangle MouseDown="OnSizeNorthEast" Name="rectSizeNorthEast" Cursor="SizeNESW" Fill="Transparent" Width="10" Height="10" VerticalAlignment="Top" HorizontalAlignment="Right" />
                        <Rectangle MouseDown="OnSizeSouthWest" Name="rectSizeSouthWest" Cursor="SizeNESW" Fill="Transparent" Width="10" Height="10" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
                        <Rectangle MouseDown="OnSizeSouthEast" Name="rectSizeSouthEast" Cursor="SizeNWSE" Fill="Transparent" Width="10" Height="10" VerticalAlignment="Bottom" HorizontalAlignment="Right" />

                        <!-- </Sizing Contols Area> -->
						
    						</Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
